const { defineConfig } = require('@vue/cli-service')

const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,

  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'sass',
      patterns: []
    }
  },
  // 打包的目录   
  outputDir: 'dist', 
  //配置代理
  devServer: {
    open: true,
    host: '127.0.0.1',
    port: '80',
    https: false,
    hot: 'only',
    proxy: {
      //代理的地址
      ['/']: {
        //目标地址
        target: 'http://localhost:8080/api',
        //是否允许跨域
        changeOrigin: true,
        //请求路径重写
        pathRewrite: {
          ['^' + '/api']: ''
        },
        logLevel: 'debug',
        ws: false
      }
    },
    historyApiFallback: true,
    allowedHosts: "all",
  },
  //svg图标配置
  chainWebpack(config) {
    //SVG图标配置
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
})
